package leetcode;

public class LongestSuffix {

    public static void main(String[] args) {

    }

    public String longestCommonPrefix(String[] strs) {
        StringBuilder sb = new StringBuilder();
        int minLength = Integer.MAX_VALUE;
        for (int i = 0; i < strs.length; i++) {
            if (strs[i].length() < minLength) {
                minLength = strs[i].length();
            }
        }
        for (int i = 0; i < minLength; i++) {
            char curChar = strs[0].charAt(i);
            for (int j = 1; j < strs.length; j++) {
                if (strs[j].charAt(i) != curChar) {
                    return sb.toString();
                }
            }
            sb.append(curChar);
        }
        return sb.toString();
    }
}
